from PIL import Image
from PIL.ImageChops import difference
import os

output_images = r"F:\李恒\nnunet\Task205_2Dwall\png_data\P1-2_image"
output_infer = r"F:\李恒\nnunet\Task205_2Dwall\png_handle\P1-2_image"

name_list = os.listdir(output_images)
infer_list = os.listdir(output_infer)

for index, name in enumerate(infer_list):
    im1 = Image.open(output_images+'/'+name_list[index])
    im2 = Image.open(output_infer+'/'+name)

    diff = difference(im2,im1)
    # newimg = Image.blend(im1, im2, alpha=0.5)
    diff.save("./data/"+name)

